package c16多线程;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class 线程池简单示例 {

	public static void main(String[] args) {
		//多线程池
		ExecutorService es = Executors.newCachedThreadPool();
		//下面的线程池只有单条线程，所以运行时没有多线程效果
//		ExecutorService es=Executors.newSingleThreadExecutor();
		//当下面的参数为1时与上面单线程池一样，>1时则为多线程池
//		ExecutorService es=Executors.newFixedThreadPool(1);

		es.submit(new ExeRunThread());
		es.submit(new ExeRunThread());

		es.shutdown();
	}

}

class ExeRunThread implements Runnable {

	@Override
	public void run() {
		for (int i = 0; i < 100; i++) {
			System.err.println(Thread.currentThread().getName() + "的i为：" + i);
		}
	}

}